//
//  TouchImage.m
//  NumLot
//
//  Created by luotao on 12-8-12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "TouchImage.h"
#import "Cons.h"

@implementation TouchImage
@synthesize eventCallback;
@synthesize touchCount;
@synthesize touchBegin;
@synthesize touchMoved;
@synthesize touchEnd;
@synthesize startX;
@synthesize currentX;
-(id)initWithImage:(UIImage *)image{
	if(!(self=[super initWithImage:image])){
		return nil;
	}
	
	self.userInteractionEnabled=YES;
	touchCount=0;
	return self;
	
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
	
    UITouch *touch = [[event allTouches] anyObject];	
	if ([touch view] != self) {
		if(LOG_DEBUG){
			NSLog(@"do something");
		}
		
	}
	if(LOG_DEBUG){
		NSLog(@"touch tag : %d",touch.view.tag);
	}
	
	CGPoint beginPoint = [[touches anyObject] locationInView:self];
	startX = beginPoint.x;
	currentX=beginPoint.x;
	
	if(touchBegin!=nil){
		[((NSObject *)eventCallback) performSelector:touchBegin withObject:touches  withObject:self];
	}
		
}

- (void) touchesMoved:(NSSet *) touches withEvent: (UIEvent *) event
{	
	if(LOG_DEBUG){
		NSLog(@"touch size : %d",[touches count]);
	}
	if(touchMoved!=nil){
		[((NSObject *)eventCallback) performSelector:touchMoved withObject:touches  withObject:self];
	}
}

- (void) touchesEnded:(NSSet *) touches withEvent: (UIEvent *) event
{
//	NSLog(@"currentX : %f",currentX);
//	[vc transOnAnimi:currentX];
	touchCount++;
	if(touchEnd!=nil){
		[((NSObject *)eventCallback) performSelector:touchEnd withObject:touches  withObject:self];
	}
}



-(void)dealloc{
	//[viewTouched release];
	[super dealloc];
}

@end
